package com.ross.mode.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 * @version 1.0.0
 * @className: JdkProxy
 * @description: 代理类工厂类
 * @author: zhangjunfa
 * @date: 2023/3/31 10:06
 */
public class ProxyFactory<T> {
    private T target;

    public ProxyFactory(T target) {
        this.target = target;
    }

    public T newInstance() {
        ProxyHandler<T> jdkProxyHandler = new ProxyHandler<T>(target);
        return (T) Proxy.newProxyInstance(target.getClass().getClassLoader(), target.getClass().getInterfaces(), jdkProxyHandler);
    }

}
